//
//  JJSearchBar.m
//  Travel assistant
//
//  Created by lanou3g on 16/2/29.
//  Copyright © 2016年 旅游助手. All rights reserved.
//

#import "JJSearchBar.h"

@implementation JJSearchBar
+ (instancetype)jjSearchBar{
    return [[self alloc] init];
}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.background = [UIImage resizedImageWithName:@"searchbar_textfield_background@2x"];
        /**左边放大镜图片*/
        UIImageView *iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"searchbar_textfield_search_icon@2x"]];
        
        iconView.contentMode = UIViewContentModeCenter;
        self.leftView = iconView;

        self.leftViewMode = UITextFieldViewModeAlways;
        
        /**字体*/
        self.font = [UIFont systemFontOfSize:13];
        /**右边的清除按钮*/
        self.clearButtonMode = UITextFieldViewModeAlways;

        //设置左边图标大小
        self.leftView.frame = CGRectMake(0, 0, 30, self.frame.size.height);
        //设置提醒文字
        NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
        attrs[NSForegroundColorAttributeName] = [UIColor grayColor];
        self.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@"搜索酒店名称....." attributes:attrs];
        
        //设置键盘右下角按钮的样式
        self.returnKeyType = UIReturnKeySearch;
        //自动设置搜索的状态
        self.enablesReturnKeyAutomatically = YES;
        
        /**设置键盘类型*/
        self.keyboardType = UIKeyboardTypeDefault;
    }
    return self;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
